<?php
	/**
	 * 创建异步TCP客户端
	 */
	$client = new swoole_client(SWOOLE_SOCK_TCP, SWOOLE_SOCK_ASYNC);

	//注册连接成功的回调
	$client->on('connect', function($cli){
		$cli->send("hello \n");
	});

	//注册数据接收
	$client->on('receive', function($cli, $data){
		echo "$data \n";
	});

	//注册连接失败
	$client->on('error', function($cli){
		echo "失败\n";
	});

	//注册关闭函数
	$client->on('close', function($cli){
		echo "关闭\n";
	});

	//发起连接
	$client->connect('127.0.0.1', 9501, 20);
